﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Nate_sRoguelikeGameXNA
{
    class Player : GameCharacter
    {
        
        public Player(string name, CharacterClass characterClass)
        {
            Name = name;
            Class = characterClass;
            Level = 1;
            Attributes = new CharacterAttributes();
            DisplayCharacter = '@';
            DisplayColor = Color.White;
            ZIndex = 100;
            ScalingAbility = 0;
        }

        public bool IsDisturbed { get; set; }

        public bool Move(Point direction)
        {
            var newLocation = MapBlock.Level.GetMapBlockAt(new Point(MapBlock.Location.X + direction.X, MapBlock.Location.Y + direction.Y));
            if (newLocation != null)
                if (newLocation.Architecture.ScalingDifficulty <= ScalingAbility)
                {
                    MapBlock = newLocation;
                    IsDisturbed = false;
                    return true;
                }
            IsDisturbed = true;
            return false;
        }

        public bool PerformAction(GameAction action)
        {
            bool result = false;
            switch (action)
            {
                case GameAction.MoveEast:
                    result = Move(new Point(1, 0));
                    break;
                case GameAction.MoveSoutheast:
                    result = Move(new Point(1, 1));
                    break;
                case GameAction.MoveSouth:
                    result = Move(new Point(0, 1));
                    break;
                case GameAction.MoveSouthwest:
                    result = Move(new Point(-1, 1));
                    break;
                case GameAction.MoveWest:
                    result = Move(new Point(-1, 0));
                    break;
                case GameAction.MoveNorthwest:
                    result = Move(new Point(-1, -1));
                    break;
                case GameAction.MoveNorth:
                    result = Move(new Point(0, -1));
                    break;
                case GameAction.MoveNortheast:
                    result = Move(new Point(1, -1));
                    break;

            }
            return result;
        }

        public void ScanArea()
        {
            IsDisturbed = false;
        }
    }
}
